// ======================================================================
// Copyright (C) 2013 Hell-Prototypes. / www.hellprototypes.com
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or (at
// your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// ======================================================================
#include "plot_raw_data.h"

plot_raw_data::plot_raw_data()
{
    m_plot_raw_data.clear();
}

size_t plot_raw_data::size() const
{
    return m_x_axis_scale;
}

QPointF plot_raw_data::sample( size_t i ) const
{
    if(i >= (size_t)m_plot_raw_data.size()) {
        //qDebug("i = %d, size = %d, m_x_axis_scale = %d", i, (size_t)m_plot_raw_data.size(), m_x_axis_scale);
        return QPointF( m_plot_raw_data.size()-1, m_plot_raw_data.at(m_plot_raw_data.size()-1) );
    } else {
        return QPointF( i, m_plot_raw_data.at(i) );
    }
}

QRectF plot_raw_data::boundingRect() const
{
    return QRectF( -128.0, 0, 128.0, m_x_axis_scale );
}

bool plot_raw_data::set_plot_raw_data(QVector<double> &plot_raw_data)
{
    m_plot_raw_data = plot_raw_data;

    return true;
}

bool plot_raw_data::set_x_axis_scale(int x_axis_scale)
{
    m_x_axis_scale = x_axis_scale;

    return true;
}
